

/***************************************************************/
//
// Function prototypes for liblwbt.so
// 
/***************************************************************/

#define byte unsigned char

struct lib_callbacks_struct {
	byte (* sdp_serve)(void);
	byte (* pin_request)(void);
	byte (* rfcomm_connect_request)(void);
	byte (* thread_stopped)(void);

	byte (* sp_connect_request)(void);
	byte (* sp_closed)(void);

	byte (*obex_transfer_request)(void);
	byte (*obex_start)(byte *obex_filename);
	byte (*obex_packet_receive)(unsigned long int total_bytes_received, unsigned long int total_bytes_expected );
	byte (*obex_done)(void);

	byte (*device_found)(void);
	byte (*scan_complete)(void);

};

struct lib_callbacks_struct *lib_callbacks;

byte hci_scan_result[2000];

/***************************************************************/
// Library control functions
/***************************************************************/
extern int lib_init(void);

extern int lib_setup(void);

extern int lib_stop(void);

extern int get_lib_status(void);

extern int lib_shutdown(void);


/***************************************************************/
// HCI local information 
/***************************************************************/
extern int get_local_name(char **local_name);

extern int set_local_name(char **local_name, int name_length);

extern int get_local_mac_addr(char **bt_mac_addr);

extern int set_scan_enable(byte value);

extern int get_device_name(byte *bt_mac_addr, char **device_name);


/***************************************************************/
// RFCOMM connection functions
/***************************************************************/

// Initiate an rfcomm connection.  If interactive_pin > 0 then
// user must continue connection process with a call to connect_pin_req
// after connect_rfcomm has returned.
extern int connect_rfcomm(byte *bt_mac_addr, byte interactive_pin);

// Continue with rfcomm connection process by supplying pin (only
// relavant if ifteractive pin requested)
extern int connect_pin_req(char *pin, byte pinlen);

// Open up fifos ad start endless fifo serving loop
extern int connect_dev_io(void);



/***************************************************************/
// Other functions 
/***************************************************************/

// Have library start serving sdp records (phybus needs to be polled 
// from external using repeated calls to check_input())
extern int sdp_serv_start(void);

// Scan for devices
extern int hci_scan(char **return_string, byte scan_time, byte lib_threaded);

// Check the phybus (raw HCI data coming in from CSR chip) a 
// specified # of times 
extern int check_input(int num_loops);

